1 Imports System.Data.SqlClient
2 Imports Excel = Microsoft.Office.Interop.Excel
3 Public Class frmSalaryslip
4 Sub fillPaymentID()
5 Try
6 Dim CN As New SqlConnection(cs)
7 CN.Open()
8 adp = New SqlDataAdapter()
9 adp.SelectCommand = New SqlCommand("SELECT distinct RTRIM(PaymentID) FROM StaffPayment", CN)
10 ds = New DataSet("ds")
11 adp.Fill(ds)
12 dtable = ds.Tables(0)
13 cmbPaymentID.Items.Clear()
14 For Each drow As DataRow In dtable.Rows
15 cmbPaymentID.Items.Add(drow(0).ToString())
16 Next
17
18 Catch ex As Exception
19 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
20 End Try
21 End Sub
22
23 Private Sub frmLogs_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
24 fillPaymentID()
25 End Sub
26 Sub Reset()
27 cmbPaymentID.Text = ""
28 fillPaymentID()
29 End Sub
30 Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
31 Reset()
32 End Sub
33
34
35 Private Sub btnClose_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
36 Me.Close()
37 End Sub
38
39 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
40 Try
41 If cmbPaymentID.Text = "" Then
42 MessageBox.Show("Please select payment id", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
43 cmbPaymentID.Focus()
44 Exit Sub
45 End If
46 Cursor = Cursors.WaitCursor
47 Timer1.Enabled = True
48 Dim rpt As New rptSalarySlip 'The report you created.
49 Dim myConnection As SqlConnection
50 Dim MyCommand As New SqlCommand()
51 Dim myDA As New SqlDataAdapter()
52 Dim myDS As New DataSet 'The DataSet you created.
53 myConnection = New SqlConnection(cs)
54 MyCommand.Connection = myConnection
55 MyCommand.CommandText = "SELECT SchoolInfo.S_Id, SchoolInfo.SchoolName, SchoolInfo.Address, SchoolInfo.ContactNo, SchoolInfo.AltContactNo, SchoolInfo.FaxNo, SchoolInfo.Email, SchoolInfo.Website, SchoolInfo.Logo, SchoolInfo.RegistrationNo,SchoolInfo.DiseNo, SchoolInfo.IndexNo, SchoolInfo.EstablishedYear, SchoolInfo.Class, SchoolInfo.SchoolType, Staff.StaffID, Staff.StaffName, Staff.DateOfJoining, Staff.Gender, Staff.FatherName,Staff.TemporaryAddress, Staff.PermanentAddress, Staff.Designation, Staff.Qualifications, Staff.DOB, Staff.PhoneNo, Staff.MobileNo, Staff.Email AS Expr1, Staff.Photo, Staff.ClassType, Staff.SchoolID,Staff.AccountName, Staff.AccountNumber, Staff.Bank, Staff.Branch, Staff.IFSCcode, Staff.Status, StaffPayment.Id, StaffPayment.PaymentID, StaffPayment.DateFrom, StaffPayment.DateTo,StaffPayment.StaffID AS Expr2, StaffPayment.PresentDays, StaffPayment.Salary , StaffPayment.Advance, StaffPayment.Deduction, StaffPayment.PaymentDate, StaffPayment.ModeOfPayment,StaffPayment.PaymentModeDetails, StaffPayment.NetPay FROM SchoolInfo INNER JOIN Staff ON SchoolInfo.S_Id = Staff.SchoolID INNER JOIN StaffPayment ON Staff.St_ID = StaffPayment.StaffID where PaymentID='" & cmbPaymentID.Text & "'"
56 MyCommand.CommandType = CommandType.Text
57 myDA.SelectCommand = MyCommand
58 myDA.Fill(myDS, "StaffPayment")
59 myDA.Fill(myDS, "Staff")
60 myDA.Fill(myDS, "SchoolInfo")
61 rpt.SetDataSource(myDS)
62 frmReport.CrystalReportViewer1.ReportSource = rpt
63 frmReport.ShowDialog()
64 Catch ex As Exception
65 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
66 End Try
67 End Sub
68
69 Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
70 Cursor = Cursors.Default
71 Timer1.Enabled = False
72 End Sub
73 End Class